package lambda;

import java.util.Collections;
import java.util.Comparator;

public class LambdaDemo {
    public static void main(String[] args) {
        Comparator<String> c = new Comparator<String>() {
            public int compare(String o1, String o2) {
                return o1.length() - o2.length();
            }
        };
        //lambda表达式写法
        Comparator<String> c1 = (String o1,String o2)->{
            return o1.length() - o2.length();
        };

        //lambda表达式中参数的类型可以忽略不写
        Comparator<String> c2 = (o1, o2)->{
            return o1.length() - o2.length();
        };

        //如果方法体中只有一句代码，那么方法体的"{}"可以忽略不写，
        //并且如果这句代码含有return关键字时也要一同忽略
        Comparator<String> c3 = (o1,o2)->o1.length() - o2.length();


    }
}
